<!DOCTYPE html>
<html>
<head>
    
    <include file="Common/head"/>
    
    <link href="__CSS__/plugins/iCheck/custom.css" rel="stylesheet">
    <style>
        .checkmod{
            margin-left: 27px;
        }
            .auth_rules{
                margin-top: 3px !important;
            }
        .checkmod .bd{
            margin-left: 27px;
        }
    </style>

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>{$title}</h5>
        </div>
        <div class="ibox-content">
            <div class="row row-lg">
                <div class="col-sm-12">
                    <include file="Common/alert"/>
                    <div class="clearfix" style="width:100%;">
                        <div class="bars pull-left">
                            <div class="btn-group hidden-xs" id="exampleTableEventsToolbar" role="group">
                                <button type="button" class="btn btn-outline btn-default" href="{:U('Auth/index')}" style="padding-bottom: 8px;padding-top: 8px;">
                                    <i class="glyphicon glyphicon-chevron-left" aria-hidden="true"></i>
                                </button>
                                <button class="btn btn-default btn-outline" type="button" name="refresh" title="刷新" href="__SELF__" style="padding-bottom: 8px;padding-top: 8px;">
                                    <i class="glyphicon glyphicon-repeat"></i>
                                </button>
                            </div>
                        </div>
                    </div>
    
                    <form method="post" action="__SELF__" class="form-horizontal">
        
    
                        <volist name="node_list" id="node" >
                            
                            <div class="hr-line-dashed"></div>
                            
                            <dl class="checkmod">
                                <dt class="hd">
                                    <label class="checkbox"><input class="auth_rules rules_all" type="checkbox" name="rules[]" value="<?php echo $main_rules[$node['url']] ?>">{$node.title}</label>
                                </dt>
                                <dd class="bd">
                                    <present name="node['child']">
                                        <volist name="node['child']" id="child" >
                                            <div class="rule_check">
                                                <div>
                                                    <label class="checkbox" <notempty name="child['tip']">title='{$child.tip}'</notempty>>
                                                    <input class="auth_rules rules_row" type="checkbox" name="rules[]" value="<?php echo $auth_rules[$child['url']] ?>"/>{$child.title}
                                                    </label>
                                                </div>
                                                <notempty name="child['operator']">
                                                    <span class="divsion">&nbsp;</span>
                                                    <span class="child_row">
                                                        <volist name="child['operator']" id="op">
                                                            <label class="checkbox" <notempty name="op['tip']">title='{$op.tip}'</notempty>>
                                                                <input class="auth_rules" type="checkbox" name="rules[]" value="<?php echo $auth_rules[$op['url']] ?>"/>
                                                                {$op.title}
                                                            </label>
                                                        </volist>
                                                    </span>
                                                </notempty>
                                             </div>
                                        </volist>
                                    </present>
                                </dd>
                            </dl>
                        </volist>
                        
                        <input type="hidden" name="id" value="{:I('group_id')}"/>
        
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="submit">保存内容</button>
                                <button class="btn btn-white" type="submit" onclick="window.history.go(-1);">取消</button>
                            </div>
                        </div>
                    </form>
                </div>
                
            </div>
        </div>
    </div>
    <!-- End Panel Other -->
</div>
<include file="Common/footer"/>
<script src="__JS__/content.min.js?v=1.0.0"></script>
<script src="__JS__/plugins/iCheck/icheck.min.js"></script>
<script src="__JS__/plugins/summernote/summernote.min.js"></script>
<script src="__JS__/plugins/summernote/summernote-zh-CN.js"></script>

<script>
    $(document).ready(function(){$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",})});
    $(document).ready(function(){$(".summernote").summernote({lang:"zh-CN"})});var edit=function(){$("#eg").addClass("no-padding");$(".click2edit").summernote({lang:"zh-CN",focus:true})};var save=function(){$("#eg").removeClass("no-padding");var aHTML=$(".click2edit").code();$(".click2edit").destroy()};
</script>

<script type="text/javascript" charset="utf-8">
    +function($){
        var rules = [{$this_group.rules}];
        $('.auth_rules').each(function(){
            if( $.inArray( parseInt(this.value,10),rules )>-1 ){
                $(this).prop('checked',true);
            }
            if(this.value==''){
                $(this).closest('span').remove();
            }
        });

        //全选节点
        $('.rules_all').on('change',function(){
            $(this).closest('dl').find('dd').find('input').prop('checked',this.checked);
        });
        $('.rules_row').on('change',function(){
            $(this).closest('.rule_check').find('.child_row').find('input').prop('checked',this.checked);
        });

        $('.checkbox').each(function(){
//            $(this).qtip({
//                content: {
//                    text: $(this).attr('title'),
//                    title: $(this).text()
//                },
//                position: {
//                    my: 'bottom center',
//                    at: 'top center',
//                    target: $(this)
//                },
//                style: {
//                    classes: 'qtip-dark',
//                    tip: {
//                        corner: true,
//                        mimic: false,
//                        width: 10,
//                        height: 10
//                    }
//                }
//            });
        });

        $('select[name=group]').change(function(){
            location.href = this.value;
        });
    }(jQuery);
</script>
</body>
</html>
